home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Color;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.io.DataInputStream;
-
- public class CRegionResponse extends CDisplayResponse {
- static final int SHOW_REGION = 1;
- static final int INVERT_REGION = 4;
- static final int FLASH_ONCE = 8;
- static final int FLASH_3_TIMES = 16;
- static final int RECTANGLE_REGION = 32;
- static final int POLYGON_REGION = 64;
- static final int CLEAR_INVERT = 128;
- static final int IN_REGION = 1;
- protected short m_cLogType;
- protected int m_nFlags;
- protected int m_nButton;
- protected CPolyline m_Polyline = new CPolyline();
- protected String m_strCursorName;
- protected CKeyboard m_clsKeyboard = new CKeyboard();
- private int m_cState;
-
- void DrawObject(Graphics var1, int var2, CPolyline var3) {
- this.DrawObject(var1, var2, ((CDisplayResponse)this).GetDrawRect());
- }
-
- void InvertRect(CRect var1) {
- Graphics var2 = Globals.thePresView.GetDC().create();
- var2.setColor(Color.white);
- var2.setXORMode(Color.black);
- var2.fillRect(var1.x, var1.y, var1.width, var1.height);
- }
-
- boolean LoadFromFile(DataInputStream var1) {
- this.m_nButton = FileLoad.ReadCPlusInt(var1);
- this.m_strCursorName = FileLoad.ReadCString(var1);
- this.m_nFlags = FileLoad.ReadCPlusInt(var1);
- this.m_Polyline.LoadFromFile(var1);
- this.m_clsKeyboard.LoadFromFile(var1);
- return super.LoadFromFile(var1);
- }
-
- boolean HitTest(Point var1) {
- return (this.m_nFlags & 64) != 0 ? this.m_Polyline.inside(var1.x, var1.y) : ((CDisplayResponse)this).GetActualRect().inside(var1.x, var1.y);
- }
-
- boolean OnKeyPress(int var1, Event var2) {
- return this.m_clsKeyboard.CheckKeyPress(var1, var2);
- }
-
- public CRegionResponse() {
- super(20);
- super.m_ActionManager = new CActionManager();
- this.m_strCursorName = "";
- this.m_nButton = 17;
- this.m_cState = 0;
- this.m_nFlags = 32;
- }
-
- CResponseReturn DoResponse(int var1) {
- if ((this.m_nFlags & 8) != 0) {
- this.DrawObject((Graphics)null, 8, (CRect)((CDisplayResponse)this).GetDrawRect());
- } else if ((this.m_nFlags & 16) != 0) {
- this.DrawObject((Graphics)null, 16, (CRect)((CDisplayResponse)this).GetDrawRect());
- }
-
- return super.DoResponse(var1);
- }
-
- void InvertRgn(CPolyline var1) {
- Graphics var2 = Globals.thePresView.GetDC().create();
- var2.setColor(Color.white);
- var2.setXORMode(Color.black);
- var2.fillPolygon(var1);
- }
-
- void Invert(CRect var1) {
- if ((this.m_nFlags & 64) != 0) {
- this.InvertRgn(this.m_Polyline);
- } else {
- this.InvertRect(var1);
- }
- }
-
- CActionManager GetActionManager() {
- return super.m_ActionManager;
- }
-
- boolean OnMouseClick(int var1, int var2, Point var3, int var4, CRect var5) {
- return var4 == 7 && this.HitTest(var3) && (var1 == 2022 && (this.m_nButton & 16) != 0 || var1 == 2025 && (this.m_nButton & 16) != 0 || var1 == 2023 && (this.m_nButton & 8) != 0 || var1 == 2026 && (this.m_nButton & 8) != 0 || var1 == 2021 && (this.m_nButton & 32) != 0 || var1 == 2024 && (this.m_nButton & 32) != 0) && ((var2 & 1) > 0 && (this.m_nButton & 1) > 0 || (var2 & 2) > 0 && (this.m_nButton & 4) > 0);
- }
-
- boolean SetResponse() {
- boolean var1 = false;
- this.m_cState = 0;
- CRect var2 = new CRect();
- int var3 = 1152;
- if ((this.m_nFlags & 64) > 0) {
- var2.reshape(this.m_Polyline.GetBoundingRect());
- ++var2.width;
- ++var2.height;
- var3 |= 2;
- } else {
- var2.reshape(((CDisplayResponse)this).GetActualRect());
- }
-
- if (!Globals.thePresView.IsDefining() && (this.m_nFlags & 1) == 0) {
- var3 |= 512;
- }
-
- if (!((Rectangle)var2).equals(((CDisplayResponse)this).GetDrawRect())) {
- if (!((CDisplayResponse)this).GetDrawRect().isEmpty()) {
- Globals.thePresView.InvalidateOffScreenRect(((CDisplayResponse)this).GetDrawRect());
- }
-
- ((CDisplayResponse)this).SetDrawRect(var2);
- var1 = true;
- }
-
- Globals.thePresView.AddDrawObject((CIconObject)this, var3, var1);
- return true;
- }
-
- CPolyline GetActualPolyline() {
- return this.m_Polyline;
- }
-
- boolean OnMouseMove(int var1, Point var2, int var3, CRect var4) {
- if (var3 == 7) {
- if (this.HitTest(var2)) {
- if ((this.m_cState & 1) == 0) {
- this.m_cState |= 1;
- if ((this.m_nFlags & 4) != 0) {
- this.DrawObject((Graphics)null, 4, (CRect)((CDisplayResponse)this).GetDrawRect());
- }
-
- if ((((CResponse)this).GetResponseFlags() & 32) == 0 && super.m_ActionManager.GetIconList().size() > 0) {
- super.m_ActionManager.OnDoAction();
- Globals.thePresView.RenderAndDrawDirtyList();
- }
- }
- } else if ((this.m_cState & 1) != 0) {
- this.m_cState &= -2;
- if ((this.m_cState & 4) > 0) {
- this.DrawObject((Graphics)null, 128, (CRect)((CDisplayResponse)this).GetDrawRect());
- }
-
- if ((((CResponse)this).GetResponseFlags() & 32) == 0 && super.m_ActionManager.GetIconList().size() > 0) {
- super.m_ActionManager.RemoveDrawObjects();
- Globals.thePresView.RenderAndDrawDirtyList();
- }
- }
- }
-
- return false;
- }
-
- void DrawObject(Graphics var1, int var2, CRect var3) {
- if (var1 == null) {
- var1 = Globals.thePresView.GetDC();
- }
-
- label38:
- switch (var2) {
- case 4:
- if ((this.m_cState & 4) == 0) {
- this.Invert(var3);
- this.m_cState |= 4;
- }
- break;
- case 8:
- if ((this.m_cState & 4) != 0) {
- this.Invert(var3);
- }
-
- this.Invert(var3);
- Utils.Wait(300);
- this.Invert(var3);
- break;
- case 16:
- if ((this.m_cState & 4) != 0) {
- this.Invert(var3);
- }
-
- int var4 = 0;
-
- while(true) {
- this.Invert(var3);
- Utils.Wait(100);
- this.Invert(var3);
- Utils.Wait(100);
- ++var4;
- if (var4 >= 3) {
- break label38;
- }
- }
- case 128:
- if ((this.m_cState & 4) != 0) {
- this.Invert(var3);
- this.m_cState &= -5;
- }
- }
-
- if ((this.m_nFlags & 1) != 0) {
- var1.setColor(Color.black);
- if ((this.m_nFlags & 64) != 0) {
- var1.drawPolygon(this.m_Polyline);
- return;
- }
-
- var1.drawRect(var3.x, var3.y, var3.width - 1, var3.height - 1);
- }
-
- }
- }
-